package cn.kgc.crowdfundingadminspringboot2.service;

import cn.kgc.crowdfundingadminspringboot2.mapper.TagMapper;
import cn.kgc.crowdfundingadminspringboot2.pojo.Tag;
import cn.kgc.crowdfundingadminspringboot2.pojo.TagExample;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Service
public class TagServiceimpl implements TagService{
    @Resource
    TagMapper tagMapper;

    @Override
    public List<Tag> getAll() {
        List<Tag> tags = tagMapper.selectByExample(null);
        return tags;
    }

    @Override
    public void savetag(Tag tag) {
        tagMapper.insert(tag);

    }

    @Override
    public Tag gettagById(Integer id) {
        Tag tag = tagMapper.selectByPrimaryKey(id);
        return tag;
    }

    @Override
    public void update(Tag tag) {
       tagMapper.updateByPrimaryKeySelective(tag);

    }

    @Override
    public void batchRemove(List<Integer> tagIdList) {
        TagExample example=new TagExample();
        TagExample.Criteria criteria=example.createCriteria();
        criteria.andIdIn(tagIdList);
        tagMapper.deleteByExample(example);
    }
}
